/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.diagram.sequence.ui.properties.tabbed;

import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
import org.eclipse.uml2.uml.Connector;
import org.eclipse.uml2.uml.Lifeline;
import org.eclipse.uml2.uml.Message;
import org.eclipse.uml2.uml.NamedElement;

import com.cea.papyrus.core.tabbedproperties.AbstractSelectionElementSection;
import com.cea.papyrus.diagram.sequence.ui.filters.MessageConnectorFilter;

/**
 * Property view section to set the decomposedAs property of a {@link Lifeline}
 * 
 */
public class MessageConnectorSection extends AbstractSelectionElementSection {
	
	public MessageConnectorSection() {
		super("Connector:", new MessageConnectorFilter());
	}

	@Override
	public NamedElement getReferencedElementToDisplay() {
		return ((Message) umlElement).getConnector();
	}

	@Override
	public void removeReferencedElement() {
		((Message) getElement()).setConnector(null);	
	}

	@Override
	public void setReferencedElement(NamedElement element) {
		if (element instanceof Connector) {
			Connector connector = (Connector) element; 
			if (connector != null) {
				
				((Message) getElement()).setConnector(connector);
			}
		}
	}

	@Override
	public void createControls(Composite parent,
			TabbedPropertySheetPage tabbedPropertySheetPage) {
		
		super.createControls(parent, tabbedPropertySheetPage);
	}
}

